//	Project:	HexTower
//	File:		BaseObject.cpp
//	Author:		Mustafa Aldoori
//	Purpose:	Implementation on all Base Objects.

#include "BaseObject.h"

CBaseObject::CBaseObject( void )
{
	m_fX = 0;
	m_fY = 0;

	m_fVelX = 0;
	m_fVelY = 0;

	m_unWidth = 0;
	m_unHeight = 0;

	m_nImageID = -1;
	//m_unColor = D3DCOLOR_XRGB(255, 255, 255);

	m_nType = OBJ_BASE;
	SetGravityBool( true );
	SetLayerType( 1 );
	m_fTimeScalar = 1.0f;
}

CBaseObject::~CBaseObject( void )
{
	
}

void CBaseObject::Update( float fElapsed )
{

}

void CBaseObject::Render( void )
{
	if(m_nImageID != -1)
	{
		/*CSGD_TextureManager::GetInstance()->Draw( m_nImageID, 
			int(m_fX), int(m_fY), 1.0f, 1.0f, nullptr, 0.0f, 0.0f, 
			0.0f, DWORD(m_unColor) );*/
	}
}

RECT CBaseObject::GetRect()
{
	RECT r;
	r.left = (LONG)(GetX()-GetWidth()/2.0f);
	r.top = (LONG)(GetY()-GetHeight()/2.0f);
	r.right = (LONG)(GetX()+GetWidth()/2.0f);
	r.bottom = (LONG)(GetY()+GetHeight()/2.0f);

	return r;
}

bool CBaseObject::CheckCollision( IBaseObject * pBase )
{
	RECT r;
	BOOL isColliding =  IntersectRect( &r, &pBase->GetRect(), &GetRect() );
	if( isColliding == TRUE )
		return true;
	
	return false;
}
